using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Build.Utilities;
using System.IO;
using Microsoft.Build.Framework;

namespace BizTalk.BuildGenerator.Tasks.BRE
{
    /// <summary>
    /// Task to deploy a policy, if version details are supplied then a specific version is deployed, it just the 
    /// policy name is supplied then all versions will be deployed
    /// </summary>
    public class DeployPolicy : BaseBRETask
    {
        private string _PolicyName;

        /// <summary>
        /// The PolicyName
        /// </summary>
        [Required]
        public string PolicyName
        {
            get { return _PolicyName; }
            set { _PolicyName = value; }
        }

        /// <summary>
        /// Task execute method
        /// </summary>
        /// <returns></returns>
        public override bool Execute()
        {
            BREManager mgr = base.CreateManager();
            if (this.IsSpecificVersion)
                mgr.DeployRuleSet(this._PolicyName, this.MajorVersion, this.MinorVersion);
            else
                mgr.DeployRuleSet(this._PolicyName);
            
            return true;
        }
    }
}
